﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.MediaCenter.UI;
using PlayPrima;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Playkanaler
{
    public class PrimaTab : Tab
    {






        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
        const int bwidth = 1214;
        const int bheight = 712;



        public PrimaTab()
        {
            Title = "Högupplöst";
            View = new EpView();
        }
        public void Click(Item i)
        {
            PrimaCat ca = new PrimaCat(prima.Categories[i.Index], IE);
            Dictionary<string, object> ps = new Dictionary<string, object>();
            ps.Add("Setting", ca);
            Microsoft.MediaCenter.Hosting.PageSession.Current.GoToPage("resx://Playkanaler/Playkanaler.Resources/Default#Default", ps);

        }
        Microsoft.MediaCenter.UI.Timer t = new Microsoft.MediaCenter.UI.Timer();
        public override void Load()
        {
            if (!IsLoaded)
            {
                IE.ToolBar = 0;
                IE.StatusBar = false;
                IE.Width = bwidth;
                IE.Height = bheight;

                //IE.Visible = true;
                //form = new sprima1.Form1();



                //MessageBox.Show("load");
                Microsoft.MediaCenter.UI.Application.DeferredInvokeOnWorkerThread(doLoading, loadingDone, null);
                IsLoaded = true;


            }
        }


        SvtPrima prima = new SvtPrima();
        void doLoading(object obj)
        {
            prima.Load();

        }

        void loadingDone(object obj)
        {
            Group g = new Group();
            foreach (var c in prima.Categories)
            {
                Item i = new Item();
                i.Title = c.Title;
                i.Index = g.Count;
                i.ImageUrl = c.ImageUrl;
                i.Attributes["cid"] = c.id;

                g.Add(i);
            }
            Add(g);

        }

    }


}
